<template>

  <div>
    <el-dialog append-to-body title="为线索上报" :visible.sync="open">
      <el-form  ref="form" :model="form" :rules="rules">
        <el-form-item label="原因" prop="reason">
          <el-select v-model="form.reason">
            <el-option v-for="item in dict.type.reasons_for_reporting" :label="item.label" :value="item.label" :key="item.value"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="备注" prop="remark">
          <el-input type="textarea" v-model="form.remark" autocomplete="off"></el-input>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="open = false">取 消</el-button>
        <el-button type="primary" @click="submitForm">确 定</el-button>
      </div>
    </el-dialog>

  </div>

</template>

<script>
   import { falseClue } from '@/api/crm/clueTrack';

    export default {
        name: "false-clue",
      dicts:[ 'reasons_for_reporting' ],
      data(){
         return {
           id:null,
           open:false,
           form:{},
           rules:{
             reason:[{required:true,meaasge:'原因不能为空',trigger:'blur'}],
             remark:[{required:true,meaasge:'备注不能为空',trigger:'blur'}],
           }
         }

      },
      methods :{
          resetForm(){
            this.form={
              reason:null,
              remark:null,
            }
          },
        submitForm(){
           this.$refs.form.validate(valid =>{
             if(valid){
               this.form.id=this.id;
               falseClue(this.form).then(()=>{
                  this.$message.success('操作成功');
                  this.open=false;
                  this.$emit('success')
               })
             }
           })
        }
      },
      created() {

      },

    }

</script>

<style scoped>

</style>
